<template>
  <div class="stores_edit">
    <Row type='flex'
         justify='center'
         style="padding:60px 100px">
      <Col style="width: 1200px;">
      <Steps :current="current">
        <Step title="选择商品分类"
              class="prev"></Step>
        <Step title="填写商品信息"
              class="prev"></Step>
        <Step title="完成"
              class="complate"></Step>
      </Steps>
      </Col>
    </Row>
    <div class="first-level content-style"
         v-show='current === 0'
         style="width: 850px">
      <div class="title">
        <p></p>
        <span>商品分类</span>
      </div>
      <Form ref="formValidate1"
            :model="formValidate1"
            :rules="ruleValidate1"
            :label-width="85"
            style="width: 850px;">
        <FormItem label="所属分类："
                  prop="involvedClassify">
          <div style="display: flex;">
            <div class="classify-content">
              <div class="section-content">
                <p>选择一级分类</p>
                <ul style="overflow-y: auto;height: 222px;cursor:pointer">
                  <li v-for='(first,idx) in firstList'
                      :key='idx'
                      :class="active===idx?'selected':''"
                      @click='selectFirstClassify(first,idx)'>
                    <span>{{first.categoryName}}</span>
                    <Icon type="ios-arrow-forward"
                          size='16' />
                  </li>
                </ul>
              </div>
              <div style="margin: 0 40px;">
                <!-- <Button type="primary">
                  <Icon type="ios-arrow-forward" /></Button> -->
              </div>
              <div class="section-content">
                <p>选择二级分类</p>
                <ul style="overflow-y: auto;height: 222px;cursor:pointer">
                  <li v-for='(second,idx) in secondList'
                      :key='idx'
                      :class="active2===idx?'selected':''"
                      @click='selectSecondClassify(second,idx)'>{{second.categoryName}}</li>
                </ul>
              </div>
            </div>
            <div style="display: flex;align-items: center;margin-left: 30px;height: 32px;color: #2D8CF0;cursor: pointer;"
                 @click="addcategory">
              <Icon type="ios-add-circle"
                    size='20' /><span>新增分类</span>
            </div>
          </div>
          <div>您当前选择的商品类别是：<span style="color:rgb(242,90,83)">{{formValidate1.involvedClassify[0].categoryName}}{{formValidate1.involvedClassify[1]?'>':''}}{{formValidate1.involvedClassify[1].categoryName}}</span></div>
        </FormItem>
        <FormItem>
          <Button type="primary"
                  @click='submitOne'>下一步</Button>
        </FormItem>
      </Form>
    </div>
    <div class="second-level content-style"
         v-show='current === 1'
         style="width: 850px">
      <div class="title">
        <p></p>
        <span>商品信息</span>
      </div>
      <Form inline
            ref="formValidate2"
            :model="formValidate2"
            :rules="ruleValidate2"
            :label-width="85"
            style="width: 850px;">
        <FormItem label="商品分类："
                  prop="productClassify">
          <Input v-model="formValidate2.productClassify"
                 placeholder="请输入"
                 style="width: 118px"
                 disabled></Input>
          <span style="color:#DCDEE2;margin: 0 8px">-</span>
          <Input v-model="formValidate2.productClassify2"
                 placeholder="请输入"
                 style="width: 118px"
                 disabled></Input>
          <!-- <span style="color: #2D8CF0;margin-left: 8px;cursor:pointer"
                @click='skipTwo'>编辑</span> -->
        </FormItem>
        <FormItem label="所属组织："
                  :label-width='180'
                  prop="orgTagId">
          <Select v-model="formValidate2.orgTagId"
                  disabled
                  style="width:255px">
            <Option v-for="item in orgTagList"
                    :value="item.id"
                    :key="item.id">{{ item.tagName }}</Option>
          </Select>
        </FormItem>
        <FormItem label="商品名称："
                  prop="skuName">
          <Input v-model="formValidate2.skuName"
                 :maxlength="12"
                 @on-keyup="keyupskuName"
                 placeholder="请输入"
                 style="width: 255px"></Input>
        </FormItem>
        <FormItem label="副标题："
                  prop="subTitle"
                  :label-width='180'>
          <Input v-model="formValidate2.subTitle"
                 :maxlength="24"
                 @on-keyup="keyupsubTitle"
                 placeholder="请输入"
                 style="width: 255px"></Input>
        </FormItem>
        <FormItem label="供应商："
                  prop="supplierId">
          <Select v-model="formValidate2.supplierId"
                  filterable
                  remote
                  disabled
                  :remote-method="remoteMethod"
                  :loading="loading"
                  style="width:255px">
            <Option v-for="item in supplierList"
                    :value="item.id"
                    :key="item.id">{{ item.suppName }}</Option>
          </Select>
        </FormItem>
        <!-- <FormItem label="供应商："
                  prop="suppName"
                  v-if="this.supplierId?true:false">
          <Input v-model="formValidate2.suppName"
                 disabled
                 placeholder="请输入"
                 style="width: 255px"></Input>
        </FormItem> -->
        <FormItem label="对应设备名称："
                  prop="equipmentId"
                  :label-width='180'>
          <Select v-model="formValidate2.equipmentId"
                  filterable
                  remote
                  :remote-method="remoteMethod2"
                  :loading="loading2"
                  style="width:255px">
            <Option v-for="item in equipmentList"
                    :value="item.machineId"
                    :key="item.machineId">{{ item.name }}</Option>
          </Select>
          <!-- <Input v-model="formValidate2.equipment"
                 :maxlength="24"
                 placeholder="请输入"
                 style="width: 255px"></Input> -->
        </FormItem>
        <FormItem label="采购单价："
                  prop="standardPrice">
          <Input v-model="formValidate2.standardPrice"
                 :maxlength="24"
                 placeholder="请输入"
                 style="width: 255px"></Input>
        </FormItem>
        <Row>
          <FormItem label="商品条码："
                    prop="barcode">
            <Input v-model="formValidate2.barcode"
                   :maxlength="13"
                   :disabled="$route.query.type===1?false:true"
                   placeholder="请输入"
                   style="width: 255px"></Input>
            <Button class="btn"
                    @click="automatic"
                    style="margin-left:20px;">自动生成</Button>
            <p style="color: #808695;font-size: 12px;">如果不输入商品条码，系统将自动生成一个唯一13位编码</p>
          </FormItem>
        </Row>
        <FormItem label="商品规格："
                  prop="specification">
          <Input v-model="formValidate2.specification"
                 :maxlength="24"
                 placeholder="请输入"
                 style="width: 255px"></Input>
        </FormItem>
        <FormItem label="商品单位："
                  prop="goodsUnit"
                  :label-width='180'>
          <Select v-model="formValidate2.goodsUnit"
                  class='input-wid'
                  style='width:255px'>
            <Option v-for="(item, index) in goodsUnitList"
                    :value="item.value"
                    :key="index">{{item.label}}</Option>
          </Select>
        </FormItem>
        <FormItem label="上传图片："
                  prop="uploadList">
          <Row type="flex">
            <Col>
            <div class="demo-upload-list"
                 style="display:flex">
              <div v-for="(item,idx) in formValidate2.uploadList"
                   :key='idx'
                   style="position: relative;">
                <div style="margin-right: 20px;position:relative;">
                  <div style="font-size: 12px;color: #FFFFFF;border: 1px solid #FFFFFF;border-radius: 2px;width:56px;height:20px;line-height:20px;text-align:center;position:absolute;top:4px;left:4px;background: #e7314e;"
                       v-if="idx===0">商品主图</div>
                  <img :src="item.multUrl"
                       style="display: inline-block;width:96px;height:96px;vertical-align: top;cursor:pointer;">
                </div>
                <div style="text-align: center;width:96px;margin-left:18px;cursor:pointer;"
                     v-if="idx!==0">
                  <p style='width: 60px;height: 24px;line-height: 24px;background: #2D8CF0;border-radius: 2px;color:#fff;margin-top:8px;cursor:pointer;'
                     @click="setmaster(idx,item)">设为主图</p>
                </div>
                <div class="demo-upload-list-cover"
                     @click="removelist(item,idx)"
                     style="position: absolute; left: 0;top: 72px;background: #ED4014;opacity: 0.6;width:96px;height: 24px;line-height: 24px;color: #fff;text-align: center;cursor:pointer">
                  <span>删除</span>
                </div>
              </div>
            </div>
            </Col>
            <Col>
            <Upload ref="upload"
                    :show-upload-list="false"
                    :default-file-list="defaultList"
                    :on-success="handleSuccess"
                    :format="['jpg','jpeg','png']"
                    :max-size="5120"
                    :on-format-error="handleFormatError"
                    :on-exceeded-size="handleMaxSize"
                    :before-upload="handleBeforeUpload"
                    multiple
                    type="drag"
                    :action="$config.uploadImg"
                    style="display: inline-block;width:96px;">
              <div>
                <img :src="defaultUrl"
                     alt=""
                     style="display: inline-block;width:96px;height:96px;vertical-align: top;">
              </div>
            </Upload>
            </Col>
            <Col>
            <div style="width:132px;height:72px;line-height:18px;color: #464C5B;margin-left:16px">
              <p>建议上传图片800*800px</p>
              <p>格式支持上传jpg、png</p>
              <p>图片限制最大5M</p>
            </div>
            </Col>
          </Row>
        </FormItem>
        <FormItem label="商品关键词："
                  prop="keywords"
                  style="display: block;">
          <Row type='flex'
               align='bottom'>
            <Col>
            <Input v-model="formValidate2.keywords"
                   style="width: 320px"
                   type="textarea"
                   :maxlength="300"
                   :autosize="{ minRows: 4, maxRows: 8 }"
                   placeholder="请描述"
                   class="Row_content_input"></Input>
            </Col>
            <Col>
            <p style="margin-left: 10px;height: 25px;">{{formValidate2.keywords.length}}/300</p>
            </Col>
          </Row>
          <p style="color: #808695;font-size: 12px;">商品关键词请用空格分隔；有两个功能，一是可以作为站内关键词查询，在前台搜索框输入关键词后，能够搜索到该商品；二是作为搜索引擎收录使用.</p>
        </FormItem>
        <FormItem label="商品备注："
                  prop="remark"
                  style="display: block;">
          <Row type='flex'
               align='bottom'>
            <Col>
            <Input v-model="formValidate2.remark"
                   style="width: 320px"
                   type="textarea"
                   :maxlength="300"
                   :autosize="{ minRows: 4, maxRows: 8 }"
                   placeholder="请描述"
                   class="Row_content_input"></Input>
            </Col>
            <Col>
            <p style="margin-left: 10px;height: 25px;">{{formValidate2.remark.length}}/300</p>
            </Col>
          </Row>
        </FormItem>
        <FormItem>
          <div style="margin-top: 20px">
            <Button class="btn"
                    @click="skipTwo">上一步，完善商品信息</Button>
            <Button type="primary"
                    class="btn"
                    style="margin-left: 24px"
                    @click="submitTwo">下一步，完成商品创建</Button>
          </div>
        </FormItem>
      </Form>
    </div>
    <div class="four-level content-style"
         style="width: 120px;text-align: center;padding-top: 50px"
         v-show='current === 2'>
      <div style="color: #18BE6B;">
        <Icon type="ios-checkmark-circle-outline"
              size='35' />
      </div>
      <h3 style="margin: 10px 0 50px 0">完成商品添加({{num}})秒</h3>
      <Button type="primary"
              @click='skipList'>返回商品列表</Button>
    </div>
  </div>
</template>
<script>
import { mapState } from 'vuex'
import { getOrgAllTree } from '@/api/system/org'
import { inventoryCategoryList, supplierNopage, machineList, inventoryGoodsBar, inventoryGoodsGet, getOrgTag, inventoryGoodsEdit, inventoryGoodsCreate } from '@/api/purchase/index'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default {
  name: 'stores_edit',
  components: { Treeselect },
  computed: {
    ...mapState({
      merchantId: state => state.user.merchantId,
      userId: state => state.user.userId,
      userName: state => state.user.userName,
      orgId: state => state.user.orgId
    })
  },
  data () {
    return {
      current: 0,
      orgTagId: '',
      orgTagName: '',
      loading: false,
      loading2: false,
      orgTagList: [],
      timer: '',
      num: 3,
      active: '',
      active2: '',
      formValidate1: {
        involvedClassify: ['', '']
      },
      goodsUnitList: [
        { value: '0', label: '个' },
        { value: '1', label: '件' }
      ],
      columns: [
        {
          title: '操作者',
          key: 'skuId'
        },
        {
          title: '操作时间',
          key: 'skuId'
        },
        {
          title: '日志记录',
          key: 'skuId'
        }
      ],
      pageObj: {
        total: 0,
        pageIndex: 1,
        pageSize: 20
      },
      defaultList: [],
      firstList: [],
      secondList: [],
      ruleValidate1: {
        involvedClassify: {
          required: true,
          type: 'array',
          trigger: 'change',
          validator: (rule, value, callback) => {
            if (value[0] !== '' && value[1] !== '') {
              callback()
            } else {
              callback(new Error('请选择所属分类'))
            }
          }
        }
      },
      normalizer (node) {
        return {
          id: node.id,
          label: node.orgName,
          children: node.childList && node.childList.length ? node.childList : undefined
        }
      },
      options: [],
      clearable: false,
      defaultUrl: require('@/assets/images/add.png'),
      supplierList: [],
      supplierListAll: [],
      equipmentListAll: [],
      equipmentList: [],
      supplierId: '',
      formValidate2: {
        productClassify: '',
        productClassify2: '',
        equipmentId: '',
        suppName: '',
        skuName: '',
        subTitle: '',
        supplierId: '',
        standardPrice: '',
        barcode: '',
        specification: '',
        goodsUnit: '',
        keywords: '',
        remark: '',
        orgTagId: '',
        orgTagName: '',
        uploadList: []
      },
      ruleValidate2: {
        skuName: { required: true, message: '商品名称不能为空', trigger: 'blur' },
        supplierId: { required: true, message: '请选择供应商' },
        orgTagId: { required: true, message: '请选择所属组织', trigger: 'change' },
        standardPrice: { required: true, message: '采购单价不能为空', trigger: 'blur' },
        barcode: { required: true, message: '商品条码不能为空' },
        goodsUnit: { required: true, message: '商品单位不能为空', trigger: 'change' },
        uploadList: { required: true, message: '商品相册不能为空' }
      },
      uploadList: []
    }
  },
  watch: {
    current (val) {
      if (val === 1) {
        this.formValidate2.productClassify = this.formValidate1.involvedClassify[0].categoryName
        this.formValidate2.productClassify2 = this.formValidate1.involvedClassify[1].categoryName
        this.getShopList()
      } else if (val === 2) {
        this.num = 3
        this.timer = setInterval(() => {
          this.num--
          if (this.num === 0) {
            clearInterval(this.timer)
            this.handleReset()
          }
        }, 1000)
      }
    }
  },
  mounted () {
    this.getDetails()
  },
  methods: {
    selectFirstClassify (first, idx) {
      this.active = idx
      this.active2 = 0
      this.formValidate1.involvedClassify = ['', '']
      this.formValidate1.involvedClassify[0] = first
      inventoryCategoryList({
        merchantId: this.merchantId,
        parentId: first.sysCategoryId,
        level: 2,
        offset: 0,
        limit: 10000,
        isShow: 1
      }).then(res => {
        if (res.data.status === 200) {
          this.secondList = res.data.data.categories || []
          if (this.secondList.length) {
            this.formValidate1.involvedClassify[1] = this.secondList[this.active2]
            this.packageId = this.secondList[this.active2].sysId
            this.categoryId = this.secondList[this.active2].sysCategoryId
          }
          // if (this.packageId) {
          //   this.editPropertyList()
          // } else {
          //   this.formDynamic.list = []
          // }
        } else {
          this.$Message.error(`${res.data.error}`)
        }
      })
    },
    remoteMethod (query) {
      if (query !== '') {
        this.loading = true
        setTimeout(() => {
          this.loading = false
          supplierNopage({
            merchantId: this.merchantId,
            dispFlag: 1,
            displayOrder: 1,
            supplierTypeCode: 1,
            orgTagId: this.orgTagId,
            orgTagName: this.orgTagName,
            keyword: query
          }).then(res => {
            const result = res.data || {}
            if (res.data.status === 200) {
              this.supplierList = result.data || []
            } else {
              this.$Message.error(`${res.data.message}`)
            }
          })
        }, 200)
      }
    },
    remoteMethod2 (query) {
      if (query !== '') {
        this.loading2 = true
        setTimeout(() => {
          this.loading2 = false
          machineList(query).then(res => {
            const result = res.data || {}
            console.log(res)
            if (res.data.status === 200) {
              this.equipmentList = result.data || []
            } else {
              this.$Message.error(`${res.data.message}`)
            }
          })
        }, 200)
      }
    },
    automatic () {
      inventoryGoodsBar({
        merchantId: this.merchantId,
        categoryId: this.categoryId
      }).then(res => {
        console.log(res)
        if (res.data.status === 200) {
          this.formValidate2.barcode = res.data.data
        } else {
          this.$Message.error(`${res.data.message}`)
        }
      })
    },
    skipList () {
      clearInterval(this.timer)
      this.handleReset()
    },
    changePageIndex () {

    },
    changePageSize () {

    },
    // 获取门店列表
    getShopList () {
      getOrgAllTree({
        'merchantId': this.merchantId,
        orgType: 0,
        // perms: 'moms:product:productcreate',
        status: 1
        // id: this.orgId
        // perms: "moms:report:groupbuyanalytics"
      }).then(res => {
        if (res.data.status === 200) {
          this.options = [res.data.data]
          if (res.data.data.childList.length === 0) {
            this.formValidate2.involvedShop = res.data.data.id
          }
        } else {
          this.$Message.error(`${res.data.error}`)
        }
      })
    },
    handleBeforeUpload () {
      const check = this.formValidate2.uploadList.length < 3
      if (!check) {
        this.$Notice.warning({
          title: '最多只能上传3张图片'
        })
      }
      return check
    },
    handleSuccess (response, file, fileList) {
      if (file.response.full_img_url) {
        let imgUrl = {
          name: file.name,
          multUrl: file.response.full_img_url
        }
        this.formValidate2.uploadList.push(imgUrl)
        if (this.formValidate2.uploadList.length > 3) {
          this.formValidate2.uploadList.splice(3, this.formValidate2.uploadList.length - 3)
        }
      }
    },
    handleFormatError () {
      this.$Notice.warning({
        title: '格式支持上传jpg、png'
      })
    },
    handleMaxSize () {
      this.$Notice.warning({
        title: '图片限制最大5m'
      })
    },
    // 设置主图
    setmaster (idx, item) {
      let data = item
      this.formValidate2.uploadList.splice(idx, 1)
      this.formValidate2.uploadList.unshift(data)
    },
    // 移除图片
    removelist (file, idx) {
      this.formValidate2.uploadList.splice(idx, 1)
    },
    selectListd (data) {
      console.log(data)
      this.formValidate2.involvedShop = data.id
      this.formValidate2.orgTagId = [data.id]
      // this.$refs.formValidate.validate((valid) => { })
      // this.$refs.formValidate2.validateField('involvedShop', (valid) => { })
    },
    selectSecondClassify (second, idx) {
      this.active2 = idx
      this.formValidate1.involvedClassify[1] = second
      this.packageId = second.sysId
      this.categoryId = second.sysCategoryId
    },
    addcategory () {

    },
    getTag (orgTagId) {
      this.orgTagId = []
      getOrgTag({
        merchantId: this.merchantId,
        id: this.orgId
      }).then(res => {
        if (res.data.status === 200) {
          this.orgTagList = res.data.data
          this.orgTagList.forEach(ele => {
            this.orgTagId.push(ele.id)
          })
          if (arguments.length) {
            this.formValidate2.orgTagId = [orgTagId]
          }
        } else {
          this.$Message.error(`${res.data.error}`)
        }
      })
    },
    submitOne () {
      this.$refs.formValidate1.validate((valid) => {
        if (valid) {
          if (this.current === 2) {
            this.current = 0
          } else {
            this.current += 1
          }
        }
      })
    },
    getDetails () {
      inventoryGoodsGet({
        merchantId: this.merchantId,
        skuId: this.$route.query.id
      }).then(res => {
        if (res.data.status === 200) {
          let result = res.data.data || {}
          if (result.parentCategoryName && result.categoryName) {
            this.getshopCategoryList(result.parentCategoryName, result.categoryName)
          }
          if (!this.$route.query.type) {
            this.formValidate2.skuName = result.skuName
            this.formValidate2.barcode = result.barcode
          }
          this.formValidate2.subTitle = result.subTitle
          this.formValidate2.standardPrice = result.standardPrice + ''
          this.formValidate2.specification = result.specification
          this.formValidate2.goodsUnit = result.goodsUnit + ''
          this.formValidate2.uploadList = result.multimedia
          this.formValidate2.keywords = result.keywords
          this.formValidate2.remark = result.remark
          this.supplierId = result.supplierId
          this.categoryId = result.categoryId
          // this.formValidate2.equipmentId = result.equipmentId
          this.getTag(result.orgTagId)
          // this.remoteMethod()
          // this.remoteMethod2('12人海洋转马')
          machineList('').then(resd => {
            const resultdd = resd.data || {}
            console.log(resd)
            if (resd.data.status === 200) {
              this.equipmentListAll = resultdd.data || []
              let name = this.equipmentListAll[this.equipmentListAll.findIndex(ele => ele.machineId === result.equipmentId)].name
              this.formValidate2.equipmentId = result.equipmentId
              this.remoteMethod2(name)
            } else {
              this.$Message.error(`${resultdd.message}`)
            }
          })
          supplierNopage({
            merchantId: this.merchantId,
            dispFlag: 1,
            displayOrder: 1,
            supplierTypeCode: 1,
            orgTagId: this.orgTagId
          }).then(resd => {
            this.loading = false
            const resultd = resd.data || {}
            if (resd.data.status === 200) {
              this.supplierListAll = resultd.data || []
              let name = this.supplierListAll[this.supplierListAll.findIndex(ele => ele.id === Number(result.supplierId))].suppName
              this.formValidate2.supplierId = Number(result.supplierId)
              this.remoteMethod(name)
              this.formValidate2.suppName = name
            } else {
              this.$Message.error(`${resultd.message}`)
            }
          })
          this.multimedia = res.data.data.multimedia
        } else {
          this.$Message.error(`${res.data.message}`)
        }
      })
    },
    keyupskuName () {
      this.formValidate2.skuName = this.formValidate2.skuName.replace(/\s+/g, '')
      this.formValidate2.skuName = this.formValidate2.skuName.replace(/[^\w\u4E00-\u9FA5]/g, '')
    },
    keyupsubTitle () {
      this.formValidate2.subTitle = this.formValidate2.subTitle.replace(/\s+/g, '')
      // this.formValidate2.subTitle = this.formValidate2.subTitle.replace(/[^\w\u4E00-\u9FA5]/g, '')
    },
    // 获取分类信息
    getshopCategoryList (parentCategoryName, categoryName) {
      inventoryCategoryList({
        merchantId: this.merchantId,
        level: 1,
        offset: 0,
        limit: 10000,
        isShow: 1
      }).then(res => {
        if (res.data.status === 200) {
          console.log(res.data.data)
          this.firstList = res.data.data.categories
          this.active = this.firstList.findIndex(ele => ele.categoryName === parentCategoryName)
          this.formValidate1.involvedClassify[0] = this.firstList[this.active]
          inventoryCategoryList({
            merchantId: this.merchantId,
            parentId: this.firstList[this.active].sysCategoryId,
            level: 2,
            offset: 0,
            limit: 10000,
            isShow: 1
          }).then(resd => {
            if (resd.data.status === 200) {
              this.secondList = resd.data.data.categories
              this.active2 = this.secondList.findIndex(ele => ele.categoryName === categoryName)
              this.formValidate1.involvedClassify[1] = this.secondList[this.active2]
            } else {
              this.$Message.error(`${resd.data.error}`)
            }
          })
        } else {
          this.$Message.error(`${res.data.error}`)
        }
      })
    },
    skipTwo () {
      this.current--
    },
    submitTwo () {
      if (this.formValidate2.orgTagId.length) {
        this.formValidate2.orgTagName = this.orgTagList[this.orgTagList.findIndex(ele => ele.id === this.formValidate2.orgTagId[0])].tagName
      }
      const { skuName, standardPrice, barcode, keywords, subTitle, remark, supplierId, equipmentId, specification, goodsUnit, orgTagId, orgTagName } = this.formValidate2
      let dataparmas = {
        merchantId: this.merchantId,
        shopId: this.orgId,
        skuName,
        spuName: this.formValidate2.skuName,
        categoryId: this.categoryId,
        standardPrice,
        barcode,
        keywords,
        updater: this.userId,
        updaterName: this.userName,
        subTitle,
        remark,
        multUrlList: this.formValidate2.uploadList.map(ele => {
          return {
            multType: 0,
            multUrl: ele.multUrl
          }
        }),
        supplierId,
        equipmentId,
        specification,
        goodsUnit,
        orgTagId,
        orgTagName
      }
      let dataparmas2 = {
        merchantId: this.merchantId,
        shopId: this.orgId,
        skuName,
        spuName: this.formValidate2.skuName,
        categoryId: this.categoryId,
        standardPrice,
        barcode,
        keywords,
        creator: this.userId,
        creatorName: this.userName,
        subTitle,
        remark,
        multUrlList: this.formValidate2.uploadList.map(ele => {
          return {
            multType: 0,
            multUrl: ele.multUrl
          }
        }),
        supplierId,
        equipmentId,
        specification,
        goodsUnit,
        orgTagId,
        orgTagName
      }
      this.$refs.formValidate2.validate((val) => {
        if (val) {
          if (this.$route.query.type) {
            inventoryGoodsCreate({
              ...dataparmas2
            }).then(res => {
              if (res.data.status === 200) {
                this.$Message.success('复制成功')
                if (this.current === 2) {
                  this.current = 0
                } else {
                  this.current += 1
                }
              } else {
                this.$Message.error(`${res.data.message}`)
              }
            })
          } else {
            inventoryGoodsEdit({
              ...dataparmas,
              skuId: this.$route.query.id
            }).then(res => {
              if (res.data.status === 200) {
                this.$Message.success('编辑成功')
                if (this.current === 2) {
                  this.current = 0
                } else {
                  this.current += 1
                }
              } else {
                this.$Message.error(`${res.data.message}`)
              }
            })
          }
        }
      })
    },
    // 关闭标签
    handleReset () {
      this.$store.commit('closeTag', this.$route)
      // this.$store.commit('setTagNavList', this.$store.state.app.tagNavList.filter(item => !routeEqual(this.$route, item)))
      if (this.$store.state.app.tagNavList[this.$store.state.app.tagNavList.length - 1].name !== 'stores_list') {
        this.$nextTick(() => {
          this.$router.push({
            name: 'stores_list'
          })
        })
      }
    }
  }
}
</script>
<style lang="less">
.stores_edit {
  .prev {
    width: 46% !important;
  }
  .complate {
    width: 8% !important;
  }
  .content-style {
    margin: 0 auto !important;
  }
  .title {
    display: flex;
    margin-bottom: 30px;
    p {
      width: 8px;
      height: 20px;
      background: #2d8cf0;
      margin-right: 10px;
    }
  }
  .classify-content {
    display: flex;
    align-items: center;
    .section-content {
      width: 230px;
      height: 263px;
      border: 1px solid #e8eaec;
      border-radius: 3px;
    }
    p {
      background: #f9fafc;
      border-bottom: 1px solid #e8eaec;
      padding: 0 8px;
    }
    ul {
      margin-top: 5px;
      li {
        list-style: none;
        padding: 0 15px;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }
    }
    .selected {
      background: #f8f8f9;
      color: #2d8cf0;
    }
  }
}
</style>
